package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFootprintMapper;
import com.qf.pojo.DtsFootprint;
import com.qf.service.DtsFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/22 21:51
 */
@Service
public class DtsFootprintServiceImpl  implements DtsFootprintService {
    @Autowired
    private DtsFootprintMapper dtsFootprintMapper;
    @Override
    public Page<DtsFootprint> selectPage(Integer page, Integer limit, String sort, String order, Integer userId, Integer goodsId) {
        Page<DtsFootprint> dtsFootprintPage = new Page<>(page,limit);
        QueryWrapper<DtsFootprint> dtsFootprintQueryWrapper = new QueryWrapper<>();
dtsFootprintQueryWrapper.orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort).eq(userId!=null,"user_id",userId).eq(goodsId!=null,"goods_id",goodsId).eq("deleted",false);
        return  dtsFootprintMapper.selectPage(dtsFootprintPage,dtsFootprintQueryWrapper);
    }
}
